<!DOCTYPE html>
<html lang="en">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" type="image/png" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="My Personal Website For Blog">
  <meta name="author" content="黄宇辉">
  <meta name="keywords" content="learning note,hexo blog">
  <title>static keyword - 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/vs2015.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">

<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">

<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>ANONYMOUS</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                Home
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                Archives
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                Tags
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                About
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2019-03-16 22:03">
      March 16, 2019 pm
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.1k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      14
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
            <article class="markdown-body">
              <h3 id="今天刷C语言程序题时遇到很多关于static关键字的题目-为区分Java中的static继而回到寝室写一篇关于Java中static关键字的使用详解"><a href="#今天刷C语言程序题时遇到很多关于static关键字的题目-为区分Java中的static继而回到寝室写一篇关于Java中static关键字的使用详解" class="headerlink" title="今天刷C语言程序题时遇到很多关于static关键字的题目,为区分Java中的static继而回到寝室写一篇关于Java中static关键字的使用详解."></a>今天刷C语言程序题时遇到很多关于<code>static</code>关键字的题目,为区分Java中的<code>static</code>继而回到寝室写一篇关于Java中<code>static</code>关键字的使用详解.</h3><h3 id="先来谈谈Java中的static"><a href="#先来谈谈Java中的static" class="headerlink" title="先来谈谈Java中的static"></a>先来谈谈Java中的<code>static</code></h3><div class="hljs"><pre><code class="hljs java"><span class="hljs-string">"static方法就是没有this的方法.在static方法内部不能调用非静态方法,反过来是可以的.而且可以在没有创建任何对象的前提下,仅仅通过类本身来调用static方法.这实际上正是static方法的主要用途.   ———— 《 Java编程思想 》"</span>

总结为一句话：方便在没有创建对象的情况下来进行调用(方法/变量).</code></pre></div>

<ul>
<li><h4 id="static-变量"><a href="#static-变量" class="headerlink" title="static 变量"></a><code>static</code> 变量</h4><div class="hljs"><pre><code class="hljs java"><span class="hljs-keyword">static</span> 变量也称作静态变量.
静态变量:   静态变量被所有的对象所共享,在内存中只有一个副本.它当且仅当在类初次加载时会被初始化.
非静态变量: 是对象所拥有的,在创建对象的时候被初始化.存在多个副本,各个对象拥有的副本互不影响.</code></pre></div>
</li>
<li><h4 id="static-方法"><a href="#static-方法" class="headerlink" title="static 方法"></a><code>static</code> 方法</h4><div class="hljs"><pre><code class="hljs java">使用 <span class="hljs-keyword">static</span> 修饰的方法一般称作静态方法.由于静态方法不依赖于任何对象就可以进行访问,因此对于静态方法来内说是无法使用 <span class="hljs-keyword">this</span> 关键字的,
因为它不依附于任何对象,既然都没有对象,就谈不上 <span class="hljs-keyword">this</span> 了 ! 继而由于这个特性,在静态方法中不能访问类的非静态成员变量和非静态成员方法,
因为非静态成员方法/变量都是必须依赖具体的`对象`才能够被调用.</code></pre></div>
</li>
<li><h4 id="static-代码块"><a href="#static-代码块" class="headerlink" title="static 代码块"></a><code>static</code> 代码块</h4><div class="hljs"><pre><code class="hljs java">静态代码块以优化程序性能.<span class="hljs-keyword">static</span> 块可以置于类中的任何地方,类中可以有多个<span class="hljs-keyword">static</span>块.
在类初次被加载的时候,会按照 <span class="hljs-keyword">static</span> 代码块的顺序逐个执行,并且只会执行一次.</code></pre></div>
<h4 id="使用JDBC中简单的Data-access-obejct实例来讲解如何利用static关键字优化程序性能-っ•̀ω•́-っ✎⁾⁾"><a href="#使用JDBC中简单的Data-access-obejct实例来讲解如何利用static关键字优化程序性能-っ•̀ω•́-っ✎⁾⁾" class="headerlink" title="使用JDBC中简单的Data access obejct实例来讲解如何利用static关键字优化程序性能 ! (っ•̀ω•́)っ✎⁾⁾"></a>使用JDBC中简单的<code>Data access obejct</code>实例来讲解如何利用<code>static</code>关键字优化程序性能 ! (っ•̀ω•́)っ✎⁾⁾</h4></li>
</ul>
<ol>
<li><p>首先创建一个连接数据库的工具类,使用<code>static 代码块</code>解决重复加载驱动问题,提高性能.</p>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@ClassName</span>: JDBCUtil
 * <span class="hljs-doctag">@Description</span>: Connect to the database.
 * <span class="hljs-doctag">@author</span>: Huang Yuhui
 * <span class="hljs-doctag">@date</span>: Mar 13, 2019 3:19:41 PM
 */</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">JDBCUtil</span> </span>&#123;
	
	<span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-title">JDBCUtil</span><span class="hljs-params">()</span> </span>&#123;
		<span class="hljs-comment">// TODO Auto-generated constructor stub</span>
	&#125;

	<span class="hljs-comment">// initialize the driver of database.</span>
	<span class="hljs-keyword">static</span> &#123;
		<span class="hljs-keyword">try</span> &#123;
			Class.forName(<span class="hljs-string">"com.mysql.cj.jdbc.Driver"</span>);
		&#125; <span class="hljs-keyword">catch</span> (ClassNotFoundException e) &#123;

			e.printStackTrace();
		&#125;
    &#125;

	<span class="hljs-comment">// Return a database connection object.</span>
	<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Connection <span class="hljs-title">getConnection</span><span class="hljs-params">()</span> </span>&#123;
		Connection connection = <span class="hljs-keyword">null</span>;
		<span class="hljs-keyword">try</span> &#123;
			connection = DriverManager.getConnection(<span class="hljs-string">"jdbc:mysql://localhost/databaseName?"</span>
					+ <span class="hljs-string">"useSSL=false&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true"</span>, <span class="hljs-string">"username"</span>, <span class="hljs-string">"password"</span>);
		&#125; <span class="hljs-keyword">catch</span> (SQLException e) &#123;
			e.printStackTrace();
		&#125;
		<span class="hljs-keyword">return</span> connection;
	&#125;
	
	<span class="hljs-comment">// release the resource of connecting.</span>
	<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">freeResource</span><span class="hljs-params">(Connection connection,PreparedStatement preparedStatement,ResultSet resultSet)</span> </span>&#123;
		<span class="hljs-keyword">if</span>(connection!=<span class="hljs-keyword">null</span>) &#123;
			<span class="hljs-keyword">try</span> &#123;
				connection.close();
			&#125; <span class="hljs-keyword">catch</span> (SQLException e) &#123;
				
				e.printStackTrace();
			&#125;
		&#125;
		<span class="hljs-keyword">if</span>(preparedStatement!=<span class="hljs-keyword">null</span>) &#123;
			<span class="hljs-keyword">try</span> &#123;
				preparedStatement.close();
			&#125; <span class="hljs-keyword">catch</span> (SQLException e) &#123;
	
				e.printStackTrace();
			&#125;
		&#125;
		<span class="hljs-keyword">if</span>(resultSet!=<span class="hljs-keyword">null</span>) &#123;
			<span class="hljs-keyword">try</span> &#123;
				resultSet.close();
			&#125; <span class="hljs-keyword">catch</span> (SQLException e) &#123;
				
				e.printStackTrace();
			&#125;
		&#125;
	&#125;
&#125;</code></pre></div>
</li>
<li><p>利用<code>static</code>修饰单独抽取出来的<code>Connection</code>对象使其成为静态变量.继而使得整个<code>DAO</code>可以共享此对象.</p>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@ClassName</span>: basicConnection
 * <span class="hljs-doctag">@Description</span>: Share this object of Connection.
 * <span class="hljs-doctag">@author</span>: Huang Yuhui
 * <span class="hljs-doctag">@date</span>: Mar 13, 2019 3:15:43 PM
 */</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">basicConnection</span> </span>&#123;

	<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Connection connection = JDBCUtil.getConnection();
&#125;</code></pre></div>
</li>
<li><p>小哥就简写一下<code>DAO</code>层类,便于举例: 增加数据表信息的类 + 删除数据表信息的类 + ······</p>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@ClassName</span>: basicConnectionTest
 * <span class="hljs-doctag">@Description</span>: Insert the specified data into the database.
 * <span class="hljs-doctag">@author</span>: Huang Yuhui
 * <span class="hljs-doctag">@date</span>: Mar 16, 2019 10:40:11 PM
 */</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">InsertTest</span> </span>&#123;

	Connection connection = basicConnection.connection;

	<span class="hljs-meta">@Test</span>
	<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">insertInfoTest</span><span class="hljs-params">()</span> </span>&#123;

		System.out.println(<span class="hljs-string">"insertInfoTest : "</span> + connection);
	&#125;
&#125;</code></pre></div>

</li>
</ol>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@ClassName</span>: DeleteTest
 * <span class="hljs-doctag">@Description</span>: Delete the specified data from the database.
 * <span class="hljs-doctag">@author</span>: Huang Yuhui
 * <span class="hljs-doctag">@date</span>: Mar 16, 2019 11:05:44 PM
 */</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DeleteTest</span> </span>&#123;

	Connection connection2 = basicConnection.connection;

	<span class="hljs-meta">@Test</span>
	<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">deleteInfoTest</span><span class="hljs-params">()</span> </span>&#123;

		System.out.println(<span class="hljs-string">"deleteInfoTest : "</span> + connection2);
	&#125;
&#125;</code></pre></div>

<ol start="4">
<li><p>利用<code>JUnit</code>测试套件测试<code>Data acess object</code>中所有的测试类.</p>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@ClassName</span>: AllTest
 * <span class="hljs-doctag">@Description</span>: Test all class.
 * <span class="hljs-doctag">@author</span>: Huang Yuhui
 * <span class="hljs-doctag">@date</span>: Mar 16, 2019 11:04:58 PM
 * 
 */</span>
<span class="hljs-meta">@RunWith</span>(Suite<span class="hljs-class">.<span class="hljs-keyword">class</span>)
@<span class="hljs-title">SuiteClasses</span>(</span>&#123; InsertTest<span class="hljs-class">.<span class="hljs-keyword">class</span>, <span class="hljs-title">DeleteTest</span>.<span class="hljs-title">class</span> &#125;)
<span class="hljs-title">public</span> <span class="hljs-title">class</span> <span class="hljs-title">AllTest</span> </span>&#123;

&#125;</code></pre></div>
</li>
<li><p>输出结果如下所示.由于<code>Connection</code>对象被抽取且被<code>static</code>修饰为了静态对象.继而在整个<code>DAO</code>中可以共享这个<code>连接数据库的对象</code>.而不必每一个类中都实例化一次<code>连接数据库的对象(Connection)</code>继而提升程序的性能（づ￣3￣）づ╭❤～</p>
<div class="hljs"><pre><code class="hljs java">insertInfoTest : com.mysql.cj.jdbc.ConnectionImpl@<span class="hljs-number">158</span>a8276
deleteInfoTest : com.mysql.cj.jdbc.ConnectionImpl@<span class="hljs-number">158</span>a8276</code></pre></div>
</li>
</ol>
<ul>
<li><em>哎哟,不知觉又半夜啦! 晚安,好梦. remember love yourself deeply.</em></li>
</ul>

            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Java/">Java</a>
                    
                      <a class="hover-with-bg" href="/tags/JUnit/">JUnit</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/2019/03/31/%E5%85%A8%E5%9B%BD%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%AD%89%E7%BA%A7%E8%80%83%E8%AF%95-%E4%BA%8C%E7%BA%A7C%E8%AF%AD%E8%A8%80/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">全国计算机等级考试-二级C语言</span>
                        <span class="visible-mobile">Previous</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/2019/03/15/%E5%85%A8%E5%9B%BD%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%AD%89%E7%BA%A7%E8%80%83%E8%AF%95-Java/">
                        <span class="hidden-mobile">全国计算机等级考试-Java</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "static keyword&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  














</body>
</html>
